<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Invitation List</title>
    </h:head>
    <h:body>
        <ui:composition template="./templateuser.xhtml">
            <ui:define name="center">
                <h:form id="form">
                    
                <p:dataScroller id="invitations" value="#{invitationListBean.invitations}" var="invitation" chunkSize="10">
                    <f:facet name="header">
                        Scroll Down to Load More Invitations
                    </f:facet>

                    <h:panelGrid columns="2" style="width: 100%" columnClasses="logo,detail">
                          
                        <p:outputPanel>
                            <h:panelGrid columns="2" cellpadding="2" >
                                <h:outputText value="Event:" />
                                <h:outputText value="#{invitation.event.name}" style="font-weight: bold"/>
                                
                                <h:outputText value="From: " />
                                <h:outputText value="#{invitation.event.creator.username}" style="font-weight: bold"/>

                                <h:outputText value="Date: " />
                                <h:outputText value="#{invitation.event.date}" style="font-weight: bold">
                                    <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT+1"/>
                                </h:outputText>
                                
                                <h:outputText value="Time: " />
                                <p:outputPanel>
                                    <h:outputText value="#{invitation.event.startTime}" style="display:inline-block;font-weight: bold">
                                        <f:convertDateTime pattern="hh:mm" timeZone="GMT+1"/>
                                    </h:outputText>
                                    <p:spacer width="20"/>
                                    -
                                    <p:spacer width="20"/>
                                    <h:outputText value="#{invitation.event.endTime}" style="display:inline-block;font-weight: bold">
                                        <f:convertDateTime pattern="hh:mm" timeZone="GMT+1"/>
                                    </h:outputText>
                                </p:outputPanel>

                                <h:outputText value="Place: " />
                                <h:outputText value="#{invitation.event.place.address}, #{invitation.event.place.city.name}, #{invitation.event.place.city.nation.name}" style="font-weight: bold"/>
                            </h:panelGrid>
                        </p:outputPanel>
                        
                        <p:outputPanel style="margin-right: 20px">
                            <h:panelGrid columns="1" cellpadding="5" style="margin-right: 20px" >
                                <h:outputText value="Will you participate?" rendered="#{!invitation.replied}"/>
                                <p:outputPanel rendered="#{!invitation.replied}">
                                    
                                    <p:commandButton value="Yes" update="invitations" action="#{invitationListBean.accept()}" >
                                        <f:setPropertyActionListener value="#{invitation}" target="#{invitationListBean.selectedinvitation}" />
                                        <p:confirm header="Confirmation" message="Are you sure that you want to participate?" icon="ui-icon-alert" />
                                    </p:commandButton>
                                    <p:spacer width="50"/>
                                    <p:commandButton value="No" update="invitations" action="#{invitationListBean.decline()}" >
                                        <f:setPropertyActionListener value="#{invitation}" target="#{invitationListBean.selectedinvitation}" />
                                    </p:commandButton>
                                    
                                    <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">
                                        <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
                                        <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
                                    </p:confirmDialog>
                                    
                                </p:outputPanel>
                            </h:panelGrid>
                        </p:outputPanel> 
                        
                        
                    </h:panelGrid>
                </p:dataScroller>  
                    
                </h:form>
                
                <style type="text/css">
                    .ui-datascroller .ui-datascroller-item {
                        border-bottom: 1px solid #A8A8A8;
                        padding: 25px 10px;
                    }
                </style>
                
            </ui:define>
        </ui:composition>
    </h:body>
</html>
